package me.ingxin.android.sample.lego.activity

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import me.ingxin.android.router.annotaions.Route
import me.ingxin.android.router.utils.getIntWrap
import me.ingxin.android.sample.lego.databinding.ActivityTest1Binding

/**
 * Created by ingxin on 2022/4/26
 */
@Route("/activity/test1")
open class Test1Activity : AppCompatActivity() {

    private val binding by lazy { ActivityTest1Binding.inflate(layoutInflater) }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(binding.root)
        supportActionBar?.title = "/activity/test1"

        val a = intent?.getStringExtra("a")
        val b = intent?.getIntWrap("b",0)
        val c = intent?.getStringExtra("c")
        val ext1 = intent?.getStringExtra("ext1")

        binding.tvShow.text = "a = $a,\nb = $b,\nc = $c,\next1 = $ext1"

        binding.btnBack.setOnClickListener {
            setResult(Activity.RESULT_OK, Intent().apply {
                putExtra("result_key","接收到Test1Activity时间戳${System.currentTimeMillis()}")
            })
            onBackPressed()
        }

    }


}